﻿using MediatR;
using Microsoft.IdentityModel.Tokens;
using Traceability.Commont.Domains.ScratchTheFat;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;

namespace U.Enterprise.Api.Applications.LoginNEwSheet
{
    public class LoginCreateHandler : IRequestHandler<LoginCreateCommond, Resqults>
    {

        private readonly IBateRepository<NewLogions> _NewLogin;

        public LoginCreateHandler(IBateRepository<NewLogions> newLogin)
        {
            _NewLogin = newLogin;
        }

        public async Task<Resqults> Handle(LoginCreateCommond request, CancellationToken cancellationToken)
        {

            var list = new Resqults() { Code = 0 };



            var Login = new NewLogions()
            {
                ControlsName=request.ControlsName,
                ControlsTime=request.ControlsTime,
                Loginid=request.Loginid,
                WhatControls=request.WhatControls,

            };

         var result=await   _NewLogin.Add(Login);
            if (result != null)
            {

                list.Code = 1;

            }
            return list;

        }
    }
}
